package com.access.boot.starter.sample.web;

import com.access.boot.apisdk.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author Yangzhen
 * @date 2022/7/28 11:16
 * @since 1.0.0
 */
@ControllerAdvice
@ResponseBody
@Slf4j
public class GlobalControllerAdvice {

    @ExceptionHandler
    public Object exception(Exception e) {
        Result result = new Result();
        result.setCode(1);
        result.setMsg(e.getMessage());
        return result;
    }
}
